function sameTypeWord(s1, s2) {
    let arr1 = s1.split("");
    let arr2 = s2.split(" ");
    if (arr1.length != arr2.length) return false;
    let map = new Map();
    for (let i = 0; i < arr2.length; i++) {
        if (map.has(arr1[i])) {
            if (map.get(arr1[i]) == arr2[i]) {
                continue
            } else {
                return false
            }
        } else {
            map.set(arr1[i], arr2[i])
        }

        if (map.has(arr2[i])) {
            if (map.get(arr2[i]) == arr1[i]) {
                continue
            } else {
                return false
            }
        } else {
            map.set(arr2[i], arr1[i])
        }
    }
    return true

}

console.log(sameTypeWord("abba", "c d d c"))

console.log(sameTypeWord("cccd", "cat cat dog fish"))